package model.tests;

import filter.IFilter;
import graphs.BarGraph;
import graphs.AbstractGraph;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import model.Model;
import junit.framework.Assert;
import junit.framework.TestCase;

public class MiscTests extends TestCase
{
    private Model myModel;
    private URL myCSVURL;
    private URL myTXTURL;

    protected void setUp() throws Exception
    {
        super.setUp();
        myModel = new Model();
        File txtfile = new File("data/names.txt");
        try
        {
            myCSVURL = new URL("http://www.duke.edu/~vr28/2DTestData.csv");
            myTXTURL = txtfile.toURI().toURL();
        }
        catch (MalformedURLException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    protected void tearDown() throws Exception
    {
        super.tearDown();
    }

    public void testGetDisplayTypes()
    {
        List<AbstractGraph<?, ?>> results = myModel.getDisplayTypes(myCSVURL);
        Assert.assertFalse(results.isEmpty());
    }

    public void testGetFilterTypes()
    {
        List<IFilter<?, ?>> results = myModel.getFilters(new BarGraph());
        Assert.assertFalse(results.isEmpty());
    }

    public void testGetHeaders()
    {
        List<String> results = myModel.getHeaders(myCSVURL, new BarGraph());
        Assert.assertFalse(results.isEmpty());
        Assert.assertEquals(3, results.size());
        Assert.assertEquals("2DTestData.csv", results.get(0));
        results = myModel.getHeaders(myTXTURL, new BarGraph());
        Assert.assertFalse(results.isEmpty());
        Assert.assertEquals(3, results.size());
        Assert.assertEquals("names.txt", results.get(0));
        Assert.assertEquals("frequency", results.get(2));
    }

}
